<template>
	<div class="diglog-info streetEdit projectDialog">
		<el-dialog title="编辑" :visible.sync="dialogVisible" size='small' @close="closeDialog">
			<el-tabs>
				<el-tab-pane label="月度计划">
					<div class="clearfix search-header">
						<div style="height:65px;padding:5px 0px 0px 0px;margin-bottom:18px;float:right">
							<el-button @click="nenwPlan" style="float:right;width:120px">新增</el-button>
						</div>
					</div>
					<el-table :data="dataAll" style="width: 100%">
						<el-table-column type="index" label="序号" width="70" show-overflow-tooltip>
						</el-table-column>
						<el-table-column prop="month" label="月份" show-overflow-tooltip>
						</el-table-column>
						<el-table-column prop="monthInvestment" label="计划投资额" show-overflow-tooltip>
						</el-table-column>
						<el-table-column prop="monthConetnt" label="项目推进内容" show-overflow-tooltip>
						</el-table-column>
						<el-table-column fixed="right" label="操作" width="150">
							<template scope="row">
								<el-button @click="edit(row)" type="text" size="small">
									修改
								</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
		<edit-detail ref="editdeatil" v-if="showEdit" :showDialogId="showDialogId" :months="months" :editData="editData" :showDialog.sync="showEdit"></edit-detail>
	</div>
</template>
<script>
	import editDetail from '../../Project/projectplanDialog/Form.vue'
	
	export default {
		props: ['showDialogId'],
		created() {
			this.refresh()
		},
		mounted() {

		},
		watch: {
			dialogVisible(val) {
				this.$emit('planUpdate', val)
			},
			dialogVisible(val) {
				this.$emit('update:showDialog', val)
			}
		},
		data() {
			return {
				showEdit:false,
				dialogVisible: true, //弹出框隐藏显示
				dataAll: [],
				editData:null,
				months:[],
			}
		},
		methods: {
			refresh() {
				console.log(this.showDialogId)
				this.ajax({
					url: 'tProjectPlan/selectPlanByPid',
					data: {
						Pid: this.showDialogId
					}
				}).then(data => {
					this.dataAll = data
				})
			},
			edit(selectedRow) {
				this.ajax({
                    url: 'tProjectPlan/selectProjectPlanById?id=' + selectedRow.row.id,
                    success: function(data) {
                    	this.$refs.editdeatil.monthselect=true;
                        this.editData = data;
                    }
                })
				this.months=[];
				this.showEdit=true;
			},
			nenwPlan() {
				setTimeout(()=>{
					this.$refs.editdeatil.monthselect=false;
				},500)
				this.months=this.getMonthArray();
				this.showEdit=true;
			},
			getMonthArray(){
				var months=[];
				for(var i=0;i<this.dataAll.length;i++){
					months.push(this.dataAll[i].month);
				}
				return months;
			},
			closeDialog(){
				debugger
			}
		},
		components: {
			editDetail
		}
	}
</script>
<style lang="less">
	.streetEdit .el-form-item__error {
		top: 35px;
		left: 100px;
	}
	
	.streetEdit .el-form-item {
		min-height: 50px;
		margin-bottom: 5px;
	}
</style>
<style scoped lang="less">
	.zui-noFloat .el-col {
		float: none;
		display: inline-block;
		margin-right: -4px;
		vertical-align: top;
	}
	
	.projectDialog .desc-input {
		width: 70%;
		float: left;
	}
</style>